package vertexBuffer

import (

	"github.com/go-gl/gl/v3.3-core/gl"
)

type VertexBuffer struct {
	vbo uint32
}

func NewVertexBuffer(data []float32) *VertexBuffer {
	vb := &VertexBuffer{}
	gl.GenBuffers(1,&vb.vbo)
	gl.BindBuffer(gl.ARRAY_BUFFER,vb.vbo)
	gl.BufferData(gl.ARRAY_BUFFER,4*len(data),gl.Ptr(data),gl.STATIC_DRAW)
	return vb
}

func (v *VertexBuffer) Bind() {
	gl.BindBuffer(gl.ARRAY_BUFFER,v.vbo)
}

func (v *VertexBuffer) UnBind() {
	gl.BindBuffer(gl.ARRAY_BUFFER,0)
}